package cate.game.event.tower;

import cate.common.table.d.GDGuild;
import cate.common.table.d.GDHoardTask;
import cate.game.chat.ChatContentParam;
import cate.game.event.GameEventListener;
import cate.game.role.Role;
import cate.game.role.res.guild.po.GuildLogDetailPO;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class TowerPassedListener implements GameEventListener<TowerPassedEvent> {
    @Override
    public void onEvent(TowerPassedEvent gameEvent) {
        Role role = gameEvent.role;
        role.getHistory().action.mainTowerPass(gameEvent.passedFloor);
        role.getRes().hoard.addition.addTask(GDHoardTask.TOWER);
        if (role.getRes().guild.checkGuild().ok() && gameEvent.passedFloor % 10 == 0 && gameEvent.passedFloor != 0) {
            role.getRes().guild.getGuild().record.addRecord(
                    new GuildLogDetailPO(GDGuild.log.MAIN_TOWER_PASSED_NUM,
                            ChatContentParam.c(role.getBase().name),
                            ChatContentParam.c(ChatContentParam.TYPE_STRING, gameEvent.passedFloor)));
        }

    }
}
